<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<link rel="stylesheet" type="text/css" href="/resources/common/styles.css" />
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
	<script type="text/javascript" src="/resources/common/script.js"/>
	
	<title>#{allPages.getTitle(facesContext.externalContext.requestServletPath)}</title>
	<ui:insert name="headSection"/>
</h:head>

<h:body>
	<div id="header">
		<div id="title">#{allPages.getTitle(facesContext.externalContext.requestServletPath)}</div>
	</div>
	<div id="loginSection" style="float: right;">
		<h:form name="loginForm">
			<h:panelGroup rendered="#{loginController.isLoggedIn()}">
				<div id="serviceLogged">
					<span>
						<h:outputText value="Сервиз: #{currentEmployee.autoserviceName}" /> <br/>
					</span>	
					
					<span>
						<h:outputText value="Потребител: #{currentEmployee.username}" /> <br/>
					</span>
					
					<span>
						<h:outputText value="Позиция: #{currentEmployee.positionString}" /> <br/>
					</span>
					<span id="exitButton">
						<h:commandButton action="#{loginController.logout()}"	value="Излез" class="inTableButton"/>
					</span>
				</div>
			</h:panelGroup>
			<h:panelGroup rendered="#{!loginController.isLoggedIn()}">
				<div id="serviceNotLogged">
					<h:outputLabel value="Потребителско име">
						<h:inputText maxlength="50"  required="true" value="#{loginController.username}" />
					</h:outputLabel>
					<br />
					<h:outputLabel value="Парола">
						<h:inputSecret maxlength="50" required="true" value="#{loginController.password}" />
					</h:outputLabel>
					<br />
				<h:panelGroup rendered="#{!empty loginController.errorMessage}" >
					<span id="errorMessage">
						<h:outputText value="#{loginController.errorMessage}" />
					<br />
					</span>
				</h:panelGroup>
					<span id="LoginButton">
						<h:commandButton action="#{loginController.login()}" value="Влез" class="inTableButton" style="margin-top:15px;display:block;background-color:red;"/>
					</span>
				</div>
			</h:panelGroup>
		</h:form>
	</div>
	<div id="bottomSection" style="clear: both;">
		<div id="leftSection">
			<ui:repeat var="currEntry" value="#{usersMenuController.getMenu(currentEmployee.position)}">
				<h:panelGroup rendered="#{currEntry.type eq 'simpleGroup'}">
					<div>
						<span>
							<h:outputText value="#{currEntry.value}" />
						</span>
						<ul>
							<ui:repeat var="currEntry1" value="#{currEntry.swallowedEntries}">
								<li>
									<h:outputLink value="#{currEntry1.path}">
										#{currEntry1.value}
									</h:outputLink>	
								</li>
							</ui:repeat>			
						</ul>
					</div>
				</h:panelGroup>
				<h:panelGroup rendered="#{currEntry.type eq 'simpleEntry'}">
				<ul>
					<li>
						<h:outputLink value="#{currEntry.path}">
							#{currEntry.value}
						</h:outputLink>	
					</li>
				</ul>
				</h:panelGroup>
			</ui:repeat>
			<ui:insert name="menu" />
		</div>
		<div id="centralSection">
			<ui:insert name="pageContent" />
		</div>
	</div>
	
</h:body>
</html>